<template>
  <div id="floor">
    <van-popup
      class="floorPopup"
      close-icon="arrow-left"
      v-model="isShowFloor"
      position="bottom"
      closeable
      close-icon-position="top-left"
      @close="$store.commit('comment/isShowFloorComment', { flag: false })"
      :style="{ height: '90%' }"
    >
      <van-cell v-if="isShowFloor">
        <van-image
          slot="icon"
          class="avatar"
          round
          fit="cover"
          :src="ownerComment.avatarUrl"
        />
        <div slot="title" class="title-wrap">
          <div class="user">
            <div class="user-name">{{ ownerComment.nickname }}</div>
            <p>{{ ownerComment.time | formatDate }}</p>
          </div>
          <van-button class="like-btn" icon="good-job-o">{{
            ownerComment.likedCount | likedTotal
          }}</van-button>
        </div>

        <div slot="label">
          <p class="comment-content">{{ ownerComment.content }}</p>
        </div>
      </van-cell>
      <Comment :id="id" :type="type" v-if="isShowFloor" :floorCom="true" @loadownerComment="loadownerComment" />
    </van-popup>
  </div>
</template>

<script>
import Comment from './Comment.vue'
import { mapGetters } from 'vuex'
export default {
  name: 'FloorCommentList',
  data () {
    return {
      isShowFloor: false,
      ownerComment: {
      }
    }
  },
  props: {
    id: {
      type: [Number, String],
      required: true
    },
    type: {
      type: Number,
      required: true
    }
  },
  methods: {
    loadownerComment (val) {
      this.$nextTick(() => {
        this.ownerComment = val
      })
    }
  },
  components: {
    Comment
  },
  computed: {
    ...mapGetters(['currentItem', 'isShowFloorCom'])
  },
  watch: {
    isShowFloorCom () {
      this.isShowFloor = this.isShowFloorCom
    }
  }
}
</script>

<style scoped lang="less">
.floorPopup {
  .comment_list {
    display: flex;
    justify-content: space-between;
    background-color: #fff;
    font-size: 14px;
    color: #333;
    font-weight: 700;
    margin: 50px 0 10px;
    padding: 0 20px;
    span {
      font-weight: 400;
      color: #999;
      margin-left: 20px;
    }
    .current {
      font-weight: 700;
      color: #333;
    }
  }
  .van-cell {
    margin-top: 40px;
    .avatar {
      width: 40px;
      height: 40px;
      margin-right: 10px;
    }
    .title-wrap {
      display: flex;
      justify-content: space-between;
      align-items: center;
      .user {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
      }
      .user-name {
        color: #999;
        font-size: 14px;
      }
      p {
        font-size: 12px;
        color: #ccc;
      }
    }
  }
  .comment-content {
    font-size: 12px;
    color: #666;
    word-break: break-all;
    text-align: justify;
  }
  .comment-pubdate {
    font-size: 14px;
    color: #222;
    margin: 10px 15px 0 0;
    color: rgba(11, 61, 136, 0.753);
  }
  .bottom-info {
    display: flex;
    align-items: center;
  }
  .like-btn {
    height: 30px;
    padding: 0;
    border: none;
    font-size: 14px;
    line-height: 30px;
    margin-right: 7px;
    color: #888;
    .van-icon {
      font-size: 14px;
    }
  }
}
</style>
